package cn.homework02;
import java.util.Scanner;
public class String02 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一串字符串：");
        String str = sc.nextLine();
        System.out.println("请输入需要查询的字符串：");
        String s = sc.nextLine();
        int count=0;int next = 0;int index = 0;
        while ((index = str.indexOf(s,next)) != -1) {
            next = index + s.length();
            count++;
        }
        System.out.println(s+ "在:" + str + "中出现" + count + "次。");

    }

}
